import QtQuick 2.15
import QtCharts 2.15

ChartView {
    id: chartView
    title: "饼图"
    antialiasing: true
    animationOptions: ChartView.AllAnimations
    
    function generateRandomData(count, maxValue) {
        var values = []
        for (var i = 0; i < count; i++) {
            values.push(Math.random() * maxValue)
        }
        return values
    }
    
    Component.onCompleted: {
        var values = generateRandomData(5, 100)
        for (var i = 0; i < values.length; i++) {
            var slice = pieSeries.append("P" + i, values[i])
            if (i === 0) {
                slice.labelVisible = true
                slice.exploded = true
            }
        }
    }
    
    PieSeries {
        id: pieSeries
        name: "Pie"
    }
}

